//
//  AddressManagementCell.m
//  DWCoach
//
//  Created by Mxionlly on 2017/4/25.
//  Copyright © 2017年 周玉. All rights reserved.
//

#import "AddressManagementCell.h"
#import <SDAutoLayout/SDAutoLayout.h>

@implementation AddressManagementCell
{
    UILabel *_lbcontent;
    UILabel *_line;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setup];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setup
{

    _lbtitle = [UILabel new];
    _lbtitle.font = [UIFont systemFontOfSize:15];
    _lbtitle.textColor = [UIColor blackColor];
    
    _lbphone = [UILabel new];
    _lbphone.font =[UIFont systemFontOfSize:15];
    _lbphone.textColor = [UIColor grayColor];
    
    _lbcontent = [UILabel new];
    _lbcontent.numberOfLines = 0;
    _lbcontent.font =[UIFont systemFontOfSize:15];
    _lbcontent.textColor = [UIColor blackColor];
    
    
    _line = [UILabel new];
    _line.backgroundColor = COLOR_Line;
    _editButton = [UIButton new];
    [_editButton setImage:[UIImage imageNamed:@"icon_me_edit"] forState:UIControlStateNormal];
    
    NSArray *views = @[_lbtitle,_lbphone,_lbcontent,_line,_editButton];
    [self.contentView sd_addSubviews:views];
    
    UIView *contentView = self.contentView;
    CGFloat margin = 15;
    
    _lbtitle.sd_layout.leftSpaceToView(contentView, margin).topSpaceToView(contentView, 10).heightIs(20).rightSpaceToView(contentView,margin);
    _lbcontent.sd_layout.leftSpaceToView(contentView, margin).topSpaceToView(_lbtitle, 5).rightSpaceToView(contentView,60).autoHeightRatio(0);
    _lbphone.sd_layout.leftSpaceToView(contentView, margin).rightSpaceToView(contentView,60).topSpaceToView(_lbcontent, 5).heightIs(20);
    _editButton.sd_layout.rightSpaceToView(contentView, 15).topSpaceToView(_lbcontent, -5).widthIs(30).heightIs(30);
    _line.sd_layout.heightIs(0.5).rightSpaceToView(contentView, margin).leftSpaceToView(contentView, margin).topSpaceToView(_lbphone, 3);
}

-(void)setModel:(dataAddressModel *)model
{
    _lbtitle.text = model.Des;
    _lbcontent.text = model.DoorNumber;
    _lbphone.text = [NSString stringWithFormat:@"%@ %@",model.Name,model.Phone];
    [self setupAutoHeightWithBottomView:_line bottomMargin:5];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
